package stud.mpgame.flash.net.command;

import flash.utils.IDataOutput;

import stud.mpgame.network.Message;
import stud.mpgame.network.UserObject;

import stud.mpgame.snapshot.ICommand;
import stud.mpgame.snapshot.ISnapshot;

import stud.mpgame.flash.test.TestSnapshot;

/**
 * ...
 * @author pavel[f.pavel91@gmail.com]
 */

class TestCommand extends UserObject, implements ICommand {
	
	private var value:Int;
	private var time:Int;
	
	public function new(time:Int, value:Int) {
		super();
		this.time = time;
		this.value = value;
	}
	
	public override function writeExternal(output:IDataOutput, message:Message):Void {
        output.writeInt(time);
		output.writeInt(value);
    }
	
	public function getTime():Int {
		return time;
	}
	
	public function apply(snapshot:ISnapshot):Void {
		cast(snapshot, TestSnapshot).setValue(value);
		cast(snapshot, TestSnapshot).addTempGameObjects(cast(snapshot, TestSnapshot).getGameObject(-1), time);
	}
	
}